Ext.application({
    name: 'HelloExt',
    launch: function() {
    	
        var signUp = Ext.create('Ext.form.field.Text', {
            renderTo: Ext.get("email"),
            height: 20,
            width: 200,
            vtype: 'email', 
            defaultType: 'textfield',
            //fieldLabel: 'Notify Me',
            name: 'email',
            emptyText: 'Please Enter E-Mail Address',
            width: 250,
			cls: 'textlabel'
        
        });
		
        var submit = Ext.create('Ext.Button', {
            text: 'Notify When Complete',
            renderTo: Ext.get('submit'),
            handler: function(){
				if (signUp.validate() && !Ext.isEmpty(signUp.getValue())) {
					Ext.Ajax.request({
						url: '/resources/prelaunchemail/',
   						params: {email: signUp.getValue()},
    					success: function(response){
        					var text = response.responseText;
        					if ("success"==text){
        						var msg = Ext.get("messageLabelContainer");
        						msg.show(true);
        						msg.addCls("fadeMessage");
        						msg.dom.innerHTML = "We'll let you know once we are up ;)";
        						msg.fadeOut({ opacity: 0, duration: 5000});
        						signUp.setValue("");
        						
        					}
    					}
					});
				}
            }
        });

    
    
    }
});